package org.yx.service.smat.view_held_material_sn;

import org.dbist.dml.Page;
import org.dbist.dml.Query;
import org.yx.utils.BaseService;

import com.xiaoleilu.hutool.util.StrUtil;

/**
 * 查询已经锁定的物料批次
 * 
 * @author zxw
 * @since 2018/05/26
 **/
public class SmatViewHeldMaterialSnService extends BaseService {
	public SmatViewHeldMaterialSnOut viewHeldMaterialSn(SmatViewHeldMaterialSnIn in) throws Exception {
		Page<HeldMsn> msnPage = null;
		if (!StrUtil.isAllBlank(in.getHoldNo(), in.getMsn(), in.getMatCode())) {
			Query query = new Query(in.getPageIndex(), in.getPageSize());
			query.addFilter("orgCode", in.getUserOrgCode());
			query.addFilter("msn", in.getMsn());
			query.addFilter("holdNo", in.getHoldNo());
			query.addFilter("matCode", in.getMatCode());

			msnPage = selectPageBySqlFilePath("select_held_material_sn.sql", query, HeldMsn.class);
		}

		SmatViewHeldMaterialSnOut out = new SmatViewHeldMaterialSnOut();
		if (msnPage != null) {
			out.setHeldMsnList(msnPage.getList());
			out.setTotalSize(msnPage.getTotalSize());
		}

		return out;
	}
}